using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace Inventory.Domain.Models.Mapping
{
    public class MoviesPersonsProfessionMap : EntityTypeConfiguration<MoviesPersonsProfession>
    {
        public MoviesPersonsProfessionMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            // Table & Column Mappings
            this.ToTable("MoviesPersonsProfessions");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.MovieId).HasColumnName("MovieId");
            this.Property(t => t.PersonProfessionId).HasColumnName("PersonProfessionId");
            this.Property(t => t.PersonsProfession_Id).HasColumnName("PersonsProfession_Id");

            // Relationships
            this.HasRequired(t => t.Movie)
                .WithMany(t => t.MoviesPersonsProfessions)
                .HasForeignKey(d => d.MovieId);
            this.HasOptional(t => t.PersonsProfession)
                .WithMany(t => t.MoviesPersonsProfessions)
                .HasForeignKey(d => d.PersonsProfession_Id);

        }
    }
}
